
#ifndef __HSEARCH_H__
#define __HSEARCH_H__

/* for use  compare functions */
#ifndef __COMPAR_FN_T
#define __COMPAR_FN_T
typedef int (*__compar_fn_t) (const void *, const void *);
#endif

/* Action which shall be performed in the call the hsearch.  */
typedef 
enum 
{
    FIND,
    ENTER
}
ACTION;

typedef 
struct entry 
{
    char *key;
    void *data;
    int dt_sz;
    unsigned int type;
    
}
ENTRY;

/* Opaque type for internal use.  */
struct _ENTRY;

/* Data type for reentrant functions.  */
typedef 
struct hsearch_data 
{
    struct _ENTRY *table;
    unsigned int size;
    unsigned int filled;
}
HTAB_INFO;

/* Family of hash table handling functions.  The functions also
   have reentrant counterparts ending with _r.  The non-reentrant
   functions all work on a signle internal hashing table.  */

/* Search for entry matching ITEM.key in internal hash table.  If
   ACTION is `FIND' return found entry or signal error by returning
   NULL.  If ACTION is `ENTER' replace existing data (if any) with
   ITEM.data.  */
extern ENTRY *hsearch (struct hsearch_data *htab, ENTRY item, ACTION action);

/* Create a new hashing table which will at most contain NEL elements.  */
extern int hcreate (struct hsearch_data *htab, long nel);

/* Destroy current internal hashing table.  */
extern void hdestroy (struct hsearch_data *htab);

/* Reentrant versions which can handle multiple hashing tables at the
   same time.  */
extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval,
		      struct hsearch_data *__htab);
extern int hcreate_r (long __nel, struct hsearch_data *__htab);
extern void hdestroy_r (struct hsearch_data *__htab);


#endif /* __HSEARCH_H__ */